package vn.kiemviec.app.data;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import vn.kiemviec.app.utils.LogTools;


/**
 * Truong Tan Trung
 * 
 *
 */
public class IndustryEntry {

	public String IndustryID;
	public String IndustryTitle;
	public String JobActiveCount;
	
//	public static ArrayList<IndustryEntry> getList(){
//		
//		ArrayList<IndustryEntry> list = new ArrayList<IndustryEntry>();
//		
//		try {
//			
////			xml
//			
//			
//		} catch (Exception e) {
//			// TODO: handle exception
//			e.printStackTrace();
//		}
//		
//		for(int i=0;i<30;i++){
//			IndustryEntry entry = new IndustryEntry();
//			
//			list.add(entry);
//		}
//		return list;
//	}
	
//	[{"INDUSTRY_ID":"31","INDUSTRY_NAME":"Sales \/ Business Development","INDUSTRY_ACTIVEDJOB":"666"},
	public static ArrayList<IndustryEntry> getListFromJson(String data){
		
		ArrayList<IndustryEntry> list = new ArrayList<IndustryEntry>();
		
		try {
			
			JSONArray jrr = new JSONArray(data);
			for(int i = 0;i<jrr.length();i++){
				JSONObject jb = jrr.getJSONObject(i);
				IndustryEntry entry = new IndustryEntry();
				
				entry.IndustryID	= jb.getString("INDUSTRY_ID");
				entry.IndustryTitle	= jb.getString("INDUSTRY_NAME");
				entry.JobActiveCount= jb.getString("INDUSTRY_ACTIVEDJOB");
				
				list.add(entry);
			}
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			LogTools.error("parse industry error.");
		}
		LogTools.info("total:"+list.size() +" industries.");
		return list;
	}
}
